﻿CREATE TABLE [dbo].[Contrato] (
    [Id]                       INT             IDENTITY (1, 1) NOT NULL,
    [Nome]                     VARCHAR (50)    NOT NULL,
    [DescricaoServico]         VARCHAR (1024)  NOT NULL,
    [IdPessoa]                 INT             NOT NULL,
    [IdRepresentante]          INT             NULL,
    [IdTipoContrato]           INT             NOT NULL,
    [DataContratoInicio]       SMALLDATETIME   NOT NULL,
    [DataContratoTermino]      SMALLDATETIME   NOT NULL,
    [DataPublicacaoInicio]     SMALLDATETIME   NULL,
    [DataPublicacaoTermino]    SMALLDATETIME   NULL,
    [IdFormaPagamento]         INT             NOT NULL,
    [IdTabelaPrecoPublicidade] INT             NULL,
    [Valor]                    NUMERIC (10, 2) NULL,
    [Ativo]                    BIT             DEFAULT ('1') NOT NULL,
    PRIMARY KEY CLUSTERED ([Id] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF),
    FOREIGN KEY ([IdPessoa]) REFERENCES [dbo].[Pessoa] ([Id]) ON DELETE NO ACTION ON UPDATE NO ACTION,
    FOREIGN KEY ([IdRepresentante]) REFERENCES [dbo].[Representante] ([Id]) ON DELETE NO ACTION ON UPDATE NO ACTION,
    FOREIGN KEY ([IdTipoContrato]) REFERENCES [dbo].[TipoContrato] ([Id]) ON DELETE NO ACTION ON UPDATE NO ACTION,
    FOREIGN KEY ([IdFormaPagamento]) REFERENCES [dbo].[FormaPagamento] ([Id]) ON DELETE NO ACTION ON UPDATE NO ACTION,
    FOREIGN KEY ([IdTabelaPrecoPublicidade]) REFERENCES [dbo].[TabelaPrecoPublicidade] ([Id]) ON DELETE NO ACTION ON UPDATE NO ACTION
);



